﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Diagnostics;

namespace Skylabs.Breeze
{
    
    static class Program
    {
        public static CacheTraceListener TraceListener = new CacheTraceListener();
        public static TraceSource ServerTrace
        {
            get
            {
                lock (TraceLock)
                {
                    return _serverTrace;
                }
            }
            set
            {
                lock (TraceLock)
                {
                    _serverTrace = value;
                }
            }
        }
        private static TraceSource _serverTrace = new TraceSource("Server",SourceLevels.All);
        private static object TraceLock = new object();
        public static bool Quitting = false;
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //EventCache = new TraceEventCache();
            ServerTrace.Listeners.Add(TraceListener);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.Run(new frmServer());
           
        }

        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            //throw new NotImplementedException();
            if (System.Diagnostics.Debugger.IsAttached)
                System.Diagnostics.Debugger.Break();
            else
            {
                ErrorWindow er = new ErrorWindow((Exception)e.ExceptionObject);
                er.ShowDialog();
            }
        }
    }
}
